At init time, read data from the PS/2 mouse until there's nothing left to
authorElliot Lee <sopwith@src.gnome.org>
Tue, 8 Aug 2000 16:44:25 +0000 (16:44 +0000)
committerElliot Lee <sopwith@src.gnome.org>
Tue, 8 Aug 2000 16:44:25 +0000 (16:44 +0000)
At init time, read data from the PS/2 mouse until there's nothing left to read, in an attempt to
synchronize up with the event stream.

gdk/linux-fb/gdkinput-ps2.c

index dcce152a4fb98bf6a1709f7e1141a57affa30cd8..399dccf4ad7683e56776d89de26a2a6664c024d4 100644 (file)
@@ -782,7 +782,7 @@ handle_input_ps2(GIOChannel *gioc, GIOCondition cond, gpointer data)
 static MouseDevice *
 mouse_open(void)
 {
-  MouseDevice *retval = g_new0(MouseDevice, 1);
+  MouseDevice *retval;
   guchar buf[7];
   int i = 0;
   GIOChannel *gioc;
@@ -790,6 +790,7 @@ mouse_open(void)
   int mode;
   enum { PS2_MOUSE, FIDMOUR_MOUSE, UNKNOWN_MOUSE } type;
 
+  retval = g_new0(MouseDevice, 1);
   retval->fd = -1;
   mode = O_RDWR;
   ctmp = getenv("GDK_MOUSETYPE");
@@ -842,10 +843,13 @@ mouse_open(void)
       buf[i++] = 232; /* device resolution */
       buf[i++] = 1;
       write(retval->fd, buf, i);
-      if(read(retval->fd, buf, 3) < 0)
-       goto error;
       fcntl(retval->fd, F_SETFL, O_RDWR|O_NONBLOCK);
 
+      usleep(10000); /* sleep 10 ms, then read whatever junk we can get from the mouse, in a vain attempt
+                       to get synchronized with the event stream */
+      while((i = read(retval->fd, buf, sizeof(buf))) > 0)
+       g_print("Got %d bytes of junk from psaux\n", i);
+
       gioc = g_io_channel_unix_new(retval->fd);
       retval->fd_tag = g_io_add_watch(gioc, G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL, handle_input_ps2, retval);
       break;